{% extends 'layout.html' %}

{% block content %}
<div class="container mt-4">
    <h2>Order Confirmation</h2>
    <div class="alert alert-success">
        Your order #{{ order.order_sn }} has been placed successfully!
    </div>
    
    <div class="card mb-4">
        <div class="card-header">
            <h4>Order Summary</h4>
        </div>
        <div class="card-body">
            <div class="row">
                <div class="col-md-6">
                    <p><strong>Order Number:</strong> {{ order.order_sn }}</p>
                    <p><strong>Order Date:</strong> {{ order.created_at|date:'Y-m-d H:i' }}</p>
                    <p><strong>Status:</strong> {{ order.get_pay_status_display }}</p>
                </div>
                <div class="col-md-6">
                    <p><strong>Total Amount:</strong> ¥{{ order.total_amount }}</p>
                </div>
            </div>
        </div>
    </div>
    
    <div class="card">
        <div class="card-header">
            <h4>Order Items</h4>
        </div>
        <div class="card-body">
            <table class="table">
                <thead>
                    <tr>
                        <th>Product</th>
                        <th>Price</th>
                        <th>Quantity</th>
                        <th>Subtotal</th>
                    </tr>
                </thead>
                <tbody>
                    {% for item in order.ordergoods_set.all %}
                    <tr>
                        <td>
                            <div class="d-flex align-items-center">
                                <img src="{{ item.goods_info.goods_img.url }}" alt="{{ item.goods_info.goods_name }}" class="img-thumbnail mr-3" style="width: 60px; height: 60px;">
                                <div>
                                    <h6>{{ item.goods_info.goods_name }}</h6>
                                    <small class="text-muted">{{ item.goods_info.goods_code }}</small>
                                </div>
                            </div>
                        </td>
                        <td>¥{{ item.goods_info.goods_price }}</td>
                        <td>{{ item.goods_num }}</td>
                        <td>¥{% widthratio item.goods_info.goods_price 1 item.goods_num %}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
    
    <div class="mt-4 text-center">
        <a href="{% url 'index' %}" class="btn btn-primary">Continue Shopping</a>
    </div>
</div>
{% endblock %}